/**
  ******************************************************************************
  * @file    sh30f9xx_sa0_lcd.h
  * @author  sinowealth
  * @version V1.1.0
  * @date    2020-09-21  
  * @brief   This file provide LCD module's APIs
  ******************************************************************************
  * @attention
  *
  * SINOWEALTH IS SUPPLYING THIS SOFTWARE FOR USE EXCLUSIVELY SH_ON SINOWEALTH'S 
  * MICROCONTROLLER PRODUCTS. IT IS PROTECTED UNDER APPLICABLE COPYRIGHT LAWS. 
  * THIS SOFTWARE IS FOR GUIDANCE IN ORDER TO SAVE TIME. AS A RESULT, SINOWEALTH 
  * SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES 
  * WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR
  * THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN 
  * CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2020 Sinowealth</center></h2>
  *
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SH30F9XX_SA0_LCD_H
#define __SH30F9XX_SA0_LCD_H

#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "sh30f9xx_sa0_libcfg.h"

/** @addtogroup SH30F9xx_sa0_libcfg_StdLib_Driver
  * @{
  */

/** @addtogroup LCD_MODULE
  * @{
  */

/** @defgroup LCD_Exported_Constants
  * @{
  */
/**emum LCD_CR_CLKSEL_Type
  *@brief LCD clock select;
  */
typedef enum
{
    LCD_CLKSEL_LSI = 0,   /*!< clock LSI >*/
    LCD_CLKSEL_LSE  = 1,  /*!< clock select lse 32.768Khz Crystal >*/
}LCD_CR_CLKSEL_Type;

/**emum LCD_CR_CLKSEL_Type
  *@brief LCD duty select;
  */
typedef enum
{
    LCD_DUTY_SEL0 = 0, /*!< 1/4 duty,1/3 bias (4 COM X 40 SEG) >*/
    LCD_DUTY_SEL1 = 1, /*!< 1/8 duty,1/4 bias (8 COM X 36 SEG) >*/
    LCD_DUTY_SEL2 = 2, /*!< 1/4 duty,1/3 bias (4 COM X 40 SEG) >*/
    LCD_DUTY_SEL3 = 3, /*!< 1/5 duty,1/3 bias (5 COM X 39 SEG) >*/
    LCD_DUTY_SEL4 = 4, /*!< 1/6 duty,1/3 bias (6 COM X 38 SEG) >*/
    LCD_DUTY_SEL5 = 5, /*!< 1/6 duty,1/4 bias (6 COM X 39 SEG) >*/
}LCD_CR_DUTYSEL_Type;

/**emum LCD_CR_VOLSEL_Type
  *@brief LCD voltage select;
  */
typedef enum
{
    LCD_VOLSEL_060VDD = 0,  /*!< VLCD = 0.60VDD >*/
    LCD_VOLSEL_066VDD = 1,  /*!< VLCD = 0.66VDD >*/
    LCD_VOLSEL_072VDD = 2,  /*!< VLCD = 0.72VDD >*/
    LCD_VOLSEL_078VDD = 3,  /*!< VLCD = 0.78VDD >*/
    LCD_VOLSEL_084VDD = 4,  /*!< VLCD = 0.84VDD >*/
    LCD_VOLSEL_090VDD = 5,  /*!< VLCD = 0.90VDD >*/
    LCD_VOLSEL_096VDD = 6,  /*!< VLCD = 0.96VDD >*/
    LCD_VOLSEL_100VDD = 7,  /*!< VLCD = 1.00VDD >*/
}LCD_CR_VOLSEL_Type;

/**emum LCD_CR_MODSW_Type
  *@brief LCD MODSW STATUS;
  */
typedef enum
{
    LCD_MODSW_ON = 0,   
    LCD_MODSW_OFF = 1,  
}LCD_CR_MODSW_Type;

/**emum LCD_CR_DRVMOD_SEL_TypeDef
  * @brief  define the LCD driver mode select
  */    
typedef enum 
{ 
    LCD_DRVMOD_2400K   = 0,    /*!< LCD tradition mode ,bias resistance 2.4M >*/
    LCD_DRVMOD_30K     = 1,    /*!< LCD tradition mode ,bias resistance 30K >*/
    LCD_DRVMOD_FASTMOD = 2,    /*!< LCD fast charge mode ,bias resistance between 30K and 2.4M >*/
}LCD_CR_DRVMOD_SEL_TypeDef;

/**emum LCD_CR_CHARGETIM_CTR_TypeDef
  * @brief  define the LCD charge time control
  */    
typedef enum 
{ 
    LCD_CHARGE_TIM_8  = 0, /*!< LCD charge time 1/8 LCD com period >*/
    LCD_CHARGE_TIM_16 = 1, /*!< LCD charge time 1/16 LCD com period >*/
    LCD_CHARGE_TIM_32 = 2, /*!< LCD charge time 1/32 LCD com period >*/
    LCD_CHARGE_TIM_64 = 3, /*!< LCD charge time 1/64 LCD com period >*/
}LCD_CR_CHARGETIM_CTR_TypeDef;

/**emum LCD_CR_SCANFCONT_MODCTR_TypeDef
  * @brief  define the LCD scanf counter mode control
  */    
typedef enum 
{ 
    LCD_SCANFCONT_MODCTR_CONT  = 0, /*!< LCD MODSW=1, scanf counter continue >*/
    LCD_SCANFCONT_MODCTR_STOP  = 1, /*!< LCD MODSW=1, scanf counter stop >*/
}LCD_CR_SCANFCONT_MODCTR_TypeDef;

/**emum LCD_CR_LSI_CLKSEL_TypeDef
  * @brief  define the LCD LSI as clock source, clock select.
  */    
typedef enum 
{ 
    LCD_LSI_CLKSEL_4  = 0, /*!< APB1 1/4  >*/
    LCD_LSI_CLKSEL_3  = 1, /*!< APB1 1/3  >*/
    LCD_LSI_CLKSEL_2  = 2, /*!< APB1 1/2  >*/
    LCD_LSI_CLKSEL_1  = 3, /*!< APB1 1/1  >*/
}LCD_CR_LSI_CLKSEL_TypeDef;

/** @struct  LCD_InitTypeDef
  * @brief structure for LCD initial
  */
    typedef struct
    {   /* for CR register */
        uint32_t  LcdEN              : 1;           /*!< LCD driver : SH_ON or SH_OFF */
        uint32_t  ClockSel           : 1;           /*!< select clock :    0: LSI  1: 32.768kHZ Crystal*/
        uint32_t  Duty               : 3;           /*!< DUTY*/
        uint32_t  VolSel             : 3;           /*!< LCD voltage select*/
        uint32_t  rev0               : 1;           /*!< LCD reserved */
        uint32_t  ContrastEn         : 1;           /*!< LCD Contrast :SH_ON or SH_OFF*/
        uint32_t  LcdPortEN          : 1;           /*!< LCD PORT output enable */
        uint32_t  rev1               : 1;           /*!< LCD reserved */
        uint32_t  LcdDriverMode      : 2;           /*!< LCD driver mode*/
        uint32_t  ChargeTime         : 2;           /*!< LCD charge time*/
        uint32_t  ScanfCounter       : 1;           /*!< LCD SCAN conunter control*/
        uint32_t  ClockDIV           : 2;           /*!< LCD clock division*/
        uint32_t  rev2               : 13;          /*!< reserved*/
    } LCD_InitTypeDef;

/**
  * @}
  */

/** @addtogroup LCD_Group_Pub_Funcs
  * @{
  */
/* Fills each LCD_InitStruct member with its default value */
void LCD_StructInit(LCD_InitTypeDef *LCD_InitStruct);

/* LCD driver mould Initial function */
void LCD_Init(LCD_TypeDef *LCD_MOULD, const LCD_InitTypeDef *InitCfg);

/* LCD driver mould SH_ENABLE */
void LCD_OnOff(CmdState OnOffState);

/*! check LCD module pointer */
#define IS_LCD_MODULE(m)    (m == LCD)

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /*__SH30F9XX_SA0_LCD_H */

/**
  * @}
  */

/**
  * @}
  */

/************************ (C) COPYRIGHT Sinowealth *****END OF FILE****/
